<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/include/taglib.jsp"%>
<html>
	<head>
		<meta charset="UTF-8">
		<title>体验金投资-共富网</title>
		<meta name="keywords" content="">
		<meta name="description" content="">
		<jsp:include page="/include/wchat/head.jsp"></jsp:include>
		<link type="text/css" rel="stylesheet" href="/v2/wchat/resrc/css/invest.css">
	</head>

	<body>
		<div id="header">
			<a href="/wchatMyElite.do" class="backto">返回</a>
			<div class="title-sub">
				体验金投资
			</div>
		</div>

		<div id="wrap">
			<div class="invest-detail">
				<b class="icon-qiang"></b>
				<h1>
					共富网体验金理财产品
				</h1>
				<ul class="items">
					<li class="c1">
						总额度
					</li>
					<li class="c2">
						￥${lastEliteProduct.totalsum}
					</li>
				</ul>
				<ul class="items">
					<li class="c1">
						年化利率
					</li>
					<li class="c2 per">
						${lastEliteProduct.annualRate }%
					</li>
				</ul>
				<ul class="items">
					<li class="c1">
						投资期限
					</li>
					<li class="c2">
						${lastEliteProduct.deadline}
						<s:if test="%{#request.lastEliteProduct.isDayThe ==1}">个月</s:if>
						<s:else>天</s:else>
					</li>
				</ul>
			</div>
			<ul class="invest-money">
				<li class="c1">
					体验金余额
				</li>
				<li class="c2">
					<ins>
						￥
					</ins>
					${availableEliteMap.amount}
					<input type="hidden" id="availableEliteHidden"
								value="${availableEliteMap.amount}" />
				</li>
			</ul>
			<ul class="invest-money">
				<li class="c1">
					预期收益
				</li>
				<li class="c2">
					<ins id="exp">
						￥ 
					</ins>
					
				</li>
			</ul>
			<div class="operate-button operate-buy">
				<s:if test="%{#request.availableEliteMap.amount > 0 }">
					<a class="btn" href="/wchatEliteInvest.do" id="eliteInvestAll">立即投资</a>
				</s:if>
				<s:else>
					<a href="javascript:;" class="btn">立即投资</a>
				</s:else>
			</div>

		</div>
		<jsp:include page="/include/wchat/footer.jsp"></jsp:include>

<script type="text/javascript">
	$(function() {
		getTotalProfit();
	});

	function getTotalProfit() {
		var investAmount = Number($('#availableEliteHidden').val());
		var annualRate = Number('${lastEliteProduct.annualRate}');
		var deadline = Number('${lastEliteProduct.deadline}');
		var isDayThe = Number('${lastEliteProduct.isDayThe}');
		var profit =  0.00;
		if(isDayThe == 1){
			profit = round(investAmount * annualRate /(12 * 100) * deadline , 2);
		}else if (isDayThe == 2){
			profit = round(investAmount * annualRate /(360 * 100) * deadline , 2);
		}		
		$("#exp").after(Util.numFormat(profit,2));
	}

	// 四舍六入五成双
	function round(num, digit){
	    var ratio = Math.pow(10, digit),
	        _num = num * ratio,
	        mod = _num % 1,
	        integer = Math.floor(_num);
	    if(mod > 0.5){
	        return (integer + 1) / ratio;
	    }else if(mod < 0.5){
	        return integer / ratio;
	    }else{
	        return (integer % 2 === 0 ? integer : integer + 1) / ratio;
	    }
	}

</script>

	</body>
</html>
